﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace POVRay {
    public class Waveform : Block {
        protected string Form { get; set; }
        protected float? Exponent { get; set; }

        protected Waveform() { }

        public static Waveform Sine() {
            return new Waveform() { Form = "sine_wave" };
        }

        public static Waveform Scallop() {
            return new Waveform() { Form = "scallop_wave" };
        }

        public static Waveform Cubic() {
            return new Waveform() { Form = "cubic_wave" };
        }

        public static Waveform Ramp() {
            return new Waveform() { Form = "ramp_wave" };
        }

        public static Waveform Triangle() {
            return new Waveform() { Form = "triangle_wave" };
        }

        public static Waveform Poly(float? exponent) {
            return new Waveform() { Form = "poly_wave", Exponent = exponent };
        }

        public override string ToString(int level) {
            StringBuilder sb = new StringBuilder();
            sb.Append(Form);
            if (Exponent.HasValue) sb.Append(" " + Exponent.Value.POVRayString()); 
            return sb.ToString();
        }
    }
}
